﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using mendian;
using DXApplicationTangche.DTO;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.货号管理;

namespace DXApplicationTangche.UC.款式尺寸
{
    public partial class Frm尺寸导入预览 : DevExpress.XtraEditors.XtraForm
    {
        private String styleSonCode;
        private List<DTO尺寸> list;
        public Frm尺寸导入预览(List<DTO尺寸> list, String styleSonCode)
        {
            InitializeComponent();
            this.styleSonCode = styleSonCode;
            this.list = list;
            this.gridControl尺寸导入预览.DataSource = this.list;
            this.gridControl尺寸表.DataSource =
                    FunctionHelper
                    .JsonDeserialization<List<DTO尺寸>>(
                        RestCall
                        .httpGetMethod(
                            URL.接口url + "/size/findByStyleNameCn?styleNameCn=" + this.styleSonCode
                            )
                        );
            this.gridView尺寸表.RefreshData();
        }
        public Frm尺寸导入预览(List<DTO尺寸> list)
        {
            InitializeComponent();
            this.list = list;
            this.gridControl尺寸导入预览.DataSource = this.list;
            this.gridControl尺寸表.DataSource =
                    FunctionHelper
                    .JsonDeserialization<List<DTO尺寸>>(
                        RestCall
                        .httpGetMethod(
                            URL.接口url + "/size/findByStyleNameCn?styleNameCn=" + this.styleSonCode
                            )
                        );
            this.gridView尺寸表.RefreshData();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            Form扫工牌取工号 form = new Form扫工牌取工号();
            form.ShowDialog();
            if (!String.IsNullOrEmpty(form.mnemonic))
            {
                RestCall.PostHttp(
                    URL.接口url + "/size/saveSizeByMnemonicAndStyleCode?mnemonic=" + form.mnemonic
                                + "&styleCode=" + this.styleSonCode,
                    FunctionHelper.JsonSerialization(this.list));
                MessageBox.Show("导入成功");
            }
            else
            {
                MessageBox.Show("请重新点击");
            }
            this.Close();
        }
    }
}